import 'dart:io';

import 'package:study_demo/base/BaseController.dart';

class ReSignController extends BaseController {
  Future<void> runCommand1() async {
    // final command = 'echo';
    // final args = ['Hello, World!'];
    //
    // // 执行命令
    // final result = await Process.run(command, args);
    //
    // // 输出结果
    // print('Exit code: ${result.exitCode}');
    // final result =
    //     await Process.run('adb devices', ['/c', 'dir'], runInShell: true);
    // print('result:$result');
    final command = 'adb';
    final args = ['devices'];

    // 执行ADB命令
    final result = await Process.run(command, args, runInShell: true);

    // 输出结果
    if (result.exitCode == 0) {
      print('ADB Devices:');
      print(result.stdout);
    } else {
      print('Error executing ADB command: ${result.stderr}');
    }
  }

  Future<void> runCommand2() async {
    final command = 'apksigner';
    final args = [
      'sign',
      '--ks',
      'D:\\Work\\Project\\yz_go_plat\\android\\app\\mygo.keystore',
      '--ks-pass',
      'pass:"dswybs*OK"',
      '--key-pass',
      'pass:"dswybs*OK"',
      'C:\\Users\\Administrator\\Downloads\\test.apk'
    ];

    // final args = ['--version'];

    // 执行ADB命令
    final result = await Process.run(command, args, runInShell: true);

    // 输出结果
    if (result.exitCode == 0) {
      print(result.stdout);
    } else {
      print('Error command: ${result.stderr}');
    }
  }

  Future<void> runCommand3() async {
    final command = 'git';
    final args = ['commit and push'];

    // 执行ADB命令
    final result = await Process.run(command, args, runInShell: true);

    // 输出结果
    if (result.exitCode == 0) {
      print(result.stdout);
    } else {
      print('Error command: ${result.stderr}');
    }
  }
}
